﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_Menu_Controls_UC_Menu : System.Web.UI.UserControl
{
    BUS_Menu data = new BUS_Menu();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GV1.DataSource = data.getMenuAllStatus(1);
            GV1.DataBind();
            GV2.DataSource = data.getMenuAllStatus(2);
            GV2.DataBind();
        }
    }
    protected void drlVitri_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (drlVitri.SelectedItem.Value == "1")
        {
            GV1.Visible = true;
            GV2.Visible = false;
        }
        else
        {
            GV2.Visible = true;
            GV1.Visible = false;
        }
    }
    public string trangthai(bool tt)
    {
        if (tt)
        {
            return "Mở";
        }
        else
            return "Đóng";

    }
    protected void GV1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Sua1")
        {
            Response.Redirect("Suamenu.aspx?id_menu=" + e.CommandArgument);
        }
        if (e.CommandName == "Xoa1")
        {
            data.Menu_Delete(e.CommandArgument.ToString());
            GV1.DataSource = data.getMenuAllStatus(1);
            GV1.DataBind();
        }
    }
    protected void GV2_RowCommand1(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Sua2")
        {
            Response.Redirect("Suamenu.aspx?id_menu=" + e.CommandArgument);
        }
        if (e.CommandName == "Xoa2")
        {
            data.Menu_Delete(e.CommandArgument.ToString());
            GV2.DataSource = data.getMenuAllStatus(2);
            GV2.DataBind();
        }
        
    }
}